package com.gqj.system.hk;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 海康人脸门禁初始化
 */
@Component
public class HkSdkInitializer {

    @Autowired
    UserAlarmCallback userAlarmCallback;
    @Autowired
    HkConfig hkConfig;

    @PostConstruct
     public void init(){
        boolean isSuccess = AcsMain.createSDKInstance();
        if (isSuccess) {
            // 1.登录
            AcsMain.login_V40(hkConfig.getIp(), hkConfig.getUser(),hkConfig.getPwd(),hkConfig.getPort());
            // 2，设置报警监听
            if(AcsMain.lUserID !=-1){
                AlarmManage.setAlarmCallBack(userAlarmCallback);
            }
        }else{
            System.out.println("海康门禁sdk-初始化失败");
        }
     }
    @PreDestroy
    public void destory(){
        AcsMain.logout();
        AcsMain.hCNetSDK.NET_DVR_Cleanup();
    }
}
